package com.zr.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.zr.service.KcxgServiceljc;
import com.zr.service.XzkcServiceljc;
import com.zr.serviceImpl.KcxgSerivceImplljc;
import com.zr.serviceImpl.XzkcServiceImplljc;

public class UpdatecControllerljc extends HttpServlet{
	//修改课程信息
	KcxgServiceljc ks = new KcxgSerivceImplljc();
	XzkcServiceljc xs = new XzkcServiceImplljc();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding("utf8");
		resp.setCharacterEncoding("utf8");
		PrintWriter pw = resp.getWriter();
		int cid = Integer.parseInt(req.getParameter("cid"));
		String cname = req.getParameter("cname");
		String classtime = req.getParameter("classtime");
		String place = req.getParameter("place");
		String tname = req.getParameter("tname");
		int tid = xs.findTeacheridBytname(tname).getTid();
		boolean flag = ks.updateCourse(cid,cname, classtime, place, tid);
		if(flag){
			pw.write("1");
		}else{
			pw.write("0");
		}
		pw.flush();
		pw.close();
	
	}
}
